package com.mingmen.canting.personal;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mingmen.canting.R;
import com.mingmen.canting.adapter.PersonalWeiShenHeListAdapter;
import com.mingmen.canting.definerecycleview.SwipeRecyclerView;
import com.mingmen.canting.util.DividerItemDecoration;
import com.mingmen.canting.util.SharePreferenceUtil;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

@SuppressLint("ValidFragment")
public class PersonalWeiListragment extends Fragment implements PersonalWeiShenHeListAdapter.OnItemClickListener {

    @BindView(R.id.recyclerview)
    SwipeRecyclerView mRecyclerview;

    Unbinder unbinder;

    private String mTitle;


    private PersonalWeiShenHeListAdapter mRadioAdapter = null;
    private LinearLayoutManager mLinearLayoutManager;

    private boolean isSelectAll = false;

    private int index = 0;

    public static PersonalWeiListragment getInstance(String title) {
        PersonalWeiListragment sf = new PersonalWeiListragment();
        sf.mTitle = title;
        return sf;
    }


    String token;
    List<String> dataBeanList = new ArrayList<>();

    @BindView(R.id.layout_nodata)
    LinearLayout layout_nodata;
    @BindView(R.id.layout_select_all)
    RelativeLayout layout_select_all;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fr_personalwei, null);
        TextView card_title_tv = (TextView) v.findViewById(R.id.card_title_tv);
        card_title_tv.setText(mTitle);

        unbinder = ButterKnife.bind(this, v);
        token = (String) SharePreferenceUtil.get(getActivity(), "token", "");
        for (int i = 0; i < 10; i++) {
            dataBeanList.add("ITem" + i);
        }

        mLinearLayoutManager = new LinearLayoutManager(getActivity());
        mRecyclerview.setLayoutManager(mLinearLayoutManager);
        DividerItemDecoration itemDecorationHeader = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
        itemDecorationHeader.setDividerDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.divider_main_bg_height_1));
        mRecyclerview.addItemDecoration(itemDecorationHeader);
        mRadioAdapter = new PersonalWeiShenHeListAdapter(getActivity(), dataBeanList);
        mRadioAdapter.setOnItemClickListener(this);

        mRecyclerview.setAdapter(mRadioAdapter);
        mRadioAdapter.setDataList(dataBeanList);

        initListener();


        return v;
    }


    @Override
    public void onResume() {
        super.onResume();

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }


    private void initListener() {


    }

    @OnClick({})
    public void onViewClicked(View view) {
        switch (view.getId()) {


        }
    }



    @Override
    public void onItemClickListener(View view, int pos, PersonalWeiShenHeListAdapter.ViewName viewName, List<String> myLiveLists) {
        switch (view.getId()) {
            case R.id.btn_zhuijia:

                break;
            case R.id.view_cb:
            case R.id.layout_check:
            case R.id.check_box:

                break;

            default:

                break;
        }
    }
}